import { defineStore } from "pinia"
import { Stores } from "types/stores"
import { store } from "@/stores"

export const useUserStore = defineStore("user", () => {
  const token = ref<string>()
  /** 登录成功保存token */
  const setToken = (_token: string) => {
    token.value = _token
  }
  /** 登录 */
  const login = async (params: any) => {
    try {
      // const data = await Api.auth.authLogin(params)
      // setToken(data.token)
    } catch (error) {
      return Promise.reject(error)
    }
  }
  return {
    token,
    login,
  }
})

// 在组件setup函数外使用
export function useUserStoreWithOut() {
  return useUserStore(store)
}
